package parser;

import java.util.HashMap;
import java.util.List;

import org.jrubyparser.ast.Node;

public class Storage {

	private HashMap<String, Node> programAST;
	private HashMap<String, String> modelsFile;
	private HashMap<String, String> viewsFile;
	private HashMap<String, String> controllersFile;
	private HashMap<String, ControlFlowGraph> cfgFile;
	private static Storage storage;
	private HashMap<String, List<Method>> methodList;
	
	private Storage()
	{
		programAST = new HashMap<String, Node>();
		modelsFile = new HashMap<String, String>();
		viewsFile = new HashMap<String, String>();
		controllersFile = new HashMap<String, String>();
		cfgFile = new HashMap<String, ControlFlowGraph>();
		methodList = new HashMap<String, List<Method>>();
	}
	
	public static Storage getInstance()
	{
		if(storage == null)
			storage = new Storage();
		return storage;
	}
	
	public Storage getStorage() {
		return storage;
	}
	
	public HashMap<String, Node> getProgramAST() {
		return programAST;
	}
	
	public void setProgramAST(HashMap<String, Node> programAST) {
		this.programAST = programAST;
	}

	public HashMap<String, String> getModelsFile() {
		return modelsFile;
	}

	public void addProgramAST(String key, Node ast)
	{
		programAST.put(key, ast);
	}
	
	public void addModelsFile(String key, String code) {
		modelsFile.put(key, code);
	}

	public HashMap<String, String> getViewsFile() {
		return viewsFile;
	}

	public void addViewsFile(String key, String code) {
		modelsFile.put(key, code);
	}

	public HashMap<String, String> getControllersFile() {
		return controllersFile;
	}

	public void addControllersFile(String key, String code) {
		modelsFile.put(key, code);
	}

	public HashMap<String, ControlFlowGraph> getCfgFile() {
		return cfgFile;
	}

	public void setCfgFile(HashMap<String, ControlFlowGraph> cfgFile) {
		this.cfgFile = cfgFile;
	}
	
	public void addCfgFile(String key, ControlFlowGraph cfg) {
		cfgFile.put(key, cfg);
	}

	public HashMap<String, List<Method>> getMethodList() {
		return methodList;
	}

	public void setMethodList(HashMap<String, List<Method>> methodList) {
		this.methodList = methodList;
	}
	
	public void addMethodList(String key, List<Method> methodName) {
		//System.out.println("adding methode: "+key+";"+methodName);
		methodList.put(key, methodName);
	}
}
